package lingnan.cn.edu.User;

import java.util.ArrayList;
import java.util.List;

import lingnan.cn.edu.util.StringUtil;

public class Milkteainf {
	private String name,img,type;
	private int price,id;
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public String getImg() {
		return img;
	}
	public void setImg(String img) {
		this.img = img;
	}
	public int getPrice() {
		return price;
	}
	public void setPrice(int price) {
		this.price = price;
	}

	public String getType() {
		return type;
	}
	public void setType(String type) {
		this.type = type;
	}
	
	private StringBuilder columnPlaceholder = new StringBuilder();
	private StringBuilder paramPlaceholder = new StringBuilder();

	private List<Object> params= new ArrayList<Object>();
	
	public List<Object> getParams() {
		return params;
	}
	
	public StringBuilder getColumnPlaceholder() {
		return columnPlaceholder;
	}
	public StringBuilder getParamPlaceholder() {
		return paramPlaceholder;
	}
	
	@Override
	public String toString() {
		return "Milktea [id=" + id + ", mteaName=" + name + ", price=" + price + ", img=" + img + ", type=" + type +"]";
	}
	
public void dualDynamicSQL() {
		
		if (!StringUtil.isEmpty(id)) {
			columnPlaceholder.append("id").append(",");
			paramPlaceholder.append("?,");
			params.add(id);
		}

		if (!StringUtil.isEmpty(name)) {
			columnPlaceholder.append("mteaName").append(",");
			paramPlaceholder.append("?,");
			params.add(name);
		}
		
		
		if(!StringUtil.isEmpty(price)) {
			columnPlaceholder.append("price").append(",");
			paramPlaceholder.append("?,");
			params.add(price);			
		}
		if(!StringUtil.isEmpty(img)) {
			columnPlaceholder.append("img").append(",");
			paramPlaceholder.append("?,");
			params.add(img);
		}
		
		if(!StringUtil.isEmpty(type)) {
			columnPlaceholder.append("type").append(",");
			paramPlaceholder.append("?,");
			params.add(type);
		}
		 
		int index = columnPlaceholder.lastIndexOf(",");
		if(index!=-1) {
			columnPlaceholder.deleteCharAt(index);
			paramPlaceholder.deleteCharAt(paramPlaceholder.lastIndexOf(","));
		}
 	}
/**
 * @return the id
 */
public int getId() {
	return id;
}
/**
 * @param id the id to set
 */
public void setId(int id) {
	this.id = id;
}

}
